package com.goldplusgold.support.lib.utils;

import java.io.IOException;

import okhttp3.FormBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;

/**
 * Created by Administrator on 2017/6/3.
 */

public class NetUtils {

    public static String put(String url, String id, String prodCode, String bearbullType, String sltpType, String sltpPrice, String floatPrice, String lots) throws IOException{

        OkHttpClient okHttpClient = new OkHttpClient();
        RequestBody requestBody = new FormBody.Builder()
                .add("id", id)
                .add("prodCode", prodCode)
                .add("bearbullType", bearbullType)
                .add("sltpType", sltpType)
                .add("sltpPrice", sltpPrice)
                .add("floatPrice", floatPrice)
                .add("lots", lots)
                .build();
        Request request = new Request.Builder()
                .url(url)
                .put(requestBody)
                .build();

        Response response = okHttpClient.newCall(request)
                .execute();

        if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);

        return (response.body().string());

    }

}
